package java5.enumeration.extensible;

import java.util.Collection;

public class Test {

    public static void main(String[] args) {
        double x = Double.parseDouble("1");
        double y = Double.parseDouble("2");
        test(ExtendedOperation.class, x, y);

        test(BasicOperation.class, x, y);
    }


    private static <T extends Enum<T> & Operation> void test(
            Class<T> opEnumType, double x, double y) {
        for (Operation op : opEnumType.getEnumConstants())
            System.out.printf("%f %s %f = %f%n",x, op, y, op.apply(x, y));
    }


    private static void test2(Collection <? extends Operation> opSet, double x, double y) {
        for (Operation op : opSet)
            System.out.printf("%f %s %f = %f%n",x, op, y, op.apply(x, y));
    }


}
